﻿//-----------------------------------------------------------------------
// <copyright file="ISettingsManager.cs" company="Nathan Miller">
// Copyright (c) Nathan Miller.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
//-----------------------------------------------------------------------
namespace TileTool.Settings
{
    /// <summary>
    /// Interface for the settings manager.
    /// </summary>
    public interface ISettingsManager
    {
        /// <summary>
        /// Load the settings file at the passed path.
        /// 
        /// This function should not throw any exception in case of error.
        /// 
        /// If there is an error with the settings data, the settings manager should
        /// revert back to default values.
        /// </summary>
        /// <param name="fileName">Path to file to load settings file from.</param>
        void Load(string fileName);

        /// <summary>
        /// Save the settings to the passed file name.
        /// </summary>
        /// <param name="fileName">File name to save settings to.</param>
        void Save(string fileName);

        /// <summary>
        /// Get a settings object of the passed type.
        /// 
        /// If an object of the passed type is not loaded, a default object
        /// should be created and returned. This default object should be stored
        /// and returned for all subsequent calls of Get().
        /// </summary>
        /// <typeparam name="T">Type of settings object to get.</typeparam>
        /// <returns>Returns the settings object.</returns>
        T Get<T>() where T : class, ISettings, new();

        /// <summary>
        /// Reset all settings objects.
        /// 
        /// This should call Reset() on all allocated settings objects.
        /// </summary>
        void ResetAll();

        /// <summary>
        /// Reset the passed settings type by calling its Reset() function.
        /// </summary>
        /// <typeparam name="T">Settings type to reset.</typeparam>
        void Reset<T>() where T : class, ISettings, new();
    }
}
